/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Task20;

import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.border.Border;
import jhelper.Notices;

/**
 *
 * @author Administrator
 */
public class NoticePanel  extends JPanel{

    private static class BorderFactory {

        private static Border createTitledBorder(String string) {
            throw new UnsupportedOperationException("Not yet implemented");
        }

       
    }
    
    
    JPanel pToday=new JPanel();
    JPanel pTomorrow =new JPanel();
    
    JList lst = null;
    
    JTextField txtmsg=new JTextField(30);
    JButton btnok=new JButton("提交");

    public NoticePanel() {
        this.setLayout(new GridLayout(2, 1, 100, 5));
        this.add(pToday);
        this.add(pTomorrow);
        
        pToday.setBorder(BorderFactory.createTitledBorder("今日提示"))；
        pTomorrow.setBorder(BorderFactory.createTitledBorder("添加明日备忘"));
        
         //pToday
        pToday.setLayout(new BorderLayout());
        ArrayList 1 =new Notices().getTodayNotices();
                
        if(1==null){
            pToday.add(new JLabel("今天没什么特别的事项要做",JLabel.CENTER));
        }else{
            1st=new JLabel(1.toArray());
            1st.setSize(400,200);
            pToday.add("Center",1st);
            
        }
        //pTomorrow
       pTomorrow.setLayout(new FlowLayout.CENTER);
       pTomorrow.add(txtmsg);
       pTomorrow.add(btnok); 
       
       
       btnok.addActionListener(
               new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
               String notice=txtmsg.getText().trim();
               if(notice.length()==0){
                   return;
                   
               }
               if(new Notices().setTomorrowNotice(notice)){
                   JOptionPane.showMessageDialog(null,"成功添加一条备忘信息!");
                   txtmsg.setText("");
                   }
                   JOptionPane.showMessageDialog(null,"数据添加出现问题!");
               
            }
        }
               
               
               
               
               
               );
        
       
        
        
        
        
       
        
        
    }
    
     this.pack();
    
    
    
    
    
    

}
